package com.patterns.factory.simpleFactory;

/**
 * Created by Xiao Yiyun on 2017/4/13.
 * 简单工厂模式
 * 取消抽象工厂类
 * 将工厂实现类的内容放到静态方法中
 * 适合只有一个工厂的情况
 */
public class SimpleFactory {

    public static <T extends Product>T create(Class<T> tClass) {
        Product product = null;
        try {
            product = (Product)Class.forName(tClass.getName()).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (T)product;
    }
}